package com.seqb.server.controller;

import com.github.pagehelper.Page;
import com.seqb.annotation.Log;
import com.seqb.common.ResultVo;
import com.seqb.common.controller.BaseController;
import com.seqb.manage.paper.domain.PaperDO;
import com.seqb.manage.paper.service.PaperService;
import com.seqb.manage.user.domain.UserSubjectDO;
import com.seqb.server.service.ServerService;
import com.seqb.utils.PageUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author lilinshen
 * @title 请填写标题
 * @description 请填写相关描述
 * @date 2019/12/24
 */
@RestController
@RequestMapping("/auth")
public class ServerController extends BaseController {
    @Autowired
    private ServerService serverService;
    @Autowired
    private PaperService paperService;

    @GetMapping("/list")
    @RequiresPermissions("manage:paper:paper:list")
    @Log("试卷表列表")
    public PageUtils list(@RequestParam Map<String, Object> params) {
        //查询列表数据
        Page<PaperDO> page = paperService.list(params);
        PageUtils pageUtils = new PageUtils(page.getResult(), page.getTotal());
        return pageUtils;
    }

    @RequestMapping("/subject/select")
    @Log("科目选择表列表")
    public ResultVo subjectSelect(UserSubjectDO userSubject) {
        return serverService.subjectSelect(userSubject);
    }

    @RequestMapping("/user/subject")
    @Log("用户选择的科目")
    public ResultVo userSubject(UserSubjectDO userSubject) {
        return serverService.userSubject(userSubject);
    }


}
